import * as renforceService from '../../services/design/renforce';
import { notification } from 'antd';
/***
 * 
 * station=>x;elevation=>y1;ground_elevation=>y2
 */
export default {

    namespace: 'renforce',
    state: {
       
    },
    reducers: {
      
    },
    effects: {
        *addCapReinforcement({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(renforceService.addCapReinforcement, { ...values });
            if (res&&res.data && res.data.code == "200") {
                onSuccess(res);
                notification.info({ message: "添加配筋成功" });
            } else {
            
                onError(res&&res.data?res.data.code:'服务器未连接');
            }

        },
        *addCushionStone({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(renforceService.addCushionStone, { ...values });
            if (res&&res.data && res.data.code == "200") {
                onSuccess(res);
                notification.info({ message: "添加配筋成功" });
            } else {
            
                onError(res&&res.data?res.data.code:'服务器未连接');
            }

        },
        *addPileReinforcement({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(renforceService.addPileReinforcement, { ...values });
            if (res&&res.data && res.data.code == "200") {
                onSuccess(res);
                notification.info({ message: "添加配筋成功" });
            } else {
            
                onError(res&&res.data?res.data.code:'服务器未连接');
            }

        },
        *ironList({ payload: values}, { call, put, select }) {
            const res = yield call(renforceService.ironList, { ...values });
            if (res&&res.data && res.data.code == "200") {
                
            } else {
            
            }
            return res&&res.data&&res.data.data?res.data.data:[]

        },
        *capReinforcementList({ payload: values}, { call, put, select }) {
            const res = yield call(renforceService.capReinforcementList, { ...values });
            if (res&&res.data && res.data.code == "200") {
                
            } else {
            
            }
            return res&&res.data&&res.data.data?res.data.data:[]

        },
        *cushionStoneList({ payload: values}, { call, put, select }) {
            const res = yield call(renforceService.cushionStoneList, { ...values });
            if (res&&res.data && res.data.code == "200") {
                
            } else {
            
            }
            return res&&res.data&&res.data.data?res.data.data:[]

        },
        *pileReinforcementList({ payload: values}, { call, put, select }) {
            const res = yield call(renforceService.pileReinforcementList, { ...values });
            if (res&&res.data && res.data.code == "200") {
                
            } else {
            
            }
            return res&&res.data&&res.data.data?res.data.data:[]

        },
        *deleteCapReinforcement({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(renforceService.deleteCapReinforcement, { ...values });
            if (res&&res.data && res.data.code == "200") {
                onSuccess(res);
                notification.info({ message: "删除配筋成功" });
            } else {
            
                onError(res&&res.data?res.data.code:'服务器未连接');
            }

        },
        *deleteCushionStone({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(renforceService.deleteCushionStone, { ...values });
            if (res&&res.data && res.data.code == "200") {
                onSuccess(res);
                notification.info({ message: "删除配筋成功" });
            } else {
            
                onError(res&&res.data?res.data.code:'服务器未连接');
            }

        },
        *deletePileReinforcement({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(renforceService.deletePileReinforcement, { ...values });
            if (res&&res.data && res.data.code == "200") {
                onSuccess(res);
                notification.info({ message: "删除配筋成功" });
            } else {
            
                onError(res&&res.data?res.data.code:'服务器未连接');
            }

        },
        *getCapReinforcementDetail({ payload:values }, { call, put, select }) {
            const res = yield call(renforceService.getCapReinforcementDetail, { ...values });
            if (res&&res.data && res.data.code == "200") {

            } else {
            
            }
            return res&&res.data&&res.data.data?res.data.data:null

        },
        *getCushionStoneDetail({ payload:values }, { call, put, select }) {
            const res = yield call(renforceService.getCushionStoneDetail, { ...values });
            if (res&&res.data && res.data.code == "200") {

            } else {
            
            }
            return res&&res.data&&res.data.data?res.data.data:null

        },
        *crossTree({ payload:values }, { call, put, select }) {
            const res = yield call(renforceService.crossTree, { ...values });
            if (res&&res.data && res.data.code == "200") {

            } else {
            
            }
            return res&&res.data&&res.data.data?res.data.data:null

        },
        *crossTempList({ payload:values }, { call, put, select }) {
            const res = yield call(renforceService.crossTempList, { ...values });
            if (res&&res.data && res.data.code == "200") {

            } else {
            
            }
            return res&&res.data&&res.data.data?res.data.data:null

        },
        *getCapReinforcementDetail2({ payload:values }, { call, put, select }) {
            const res = yield call(renforceService.getCapReinforcementDetail2, { ...values });
            if (res&&res.data && res.data.code == "200") {

            } else {
            
            }
            return res&&res.data&&res.data.data?res.data.data:null

        },
        *updateCapReinforcement({ payload:{ values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(renforceService.updateCapReinforcement, { ...values });
            if (res&&res.data && res.data.code == "200") {
                onSuccess(res);
                notification.info({ message: "更新配筋成功" });
            } else {
                onError(res&&res.data?res.data.code:'服务器未连接');
            }

        },
        *exportCapReinforcement({ payload:{ values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(renforceService.exportCapReinforcement, { ...values });
            if (res&&res.data) {
                onSuccess(res.data);
                notification.info({ message: "导出配筋成功" });
            } else {
                onError(res&&res.data?res.data.code:'服务器未连接');
            }

        },
        *updateCushionStone({ payload:{ values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(renforceService.updateCushionStone, { ...values });
            
            if (res&&res.data && res.data.code == "200") {
                onSuccess(res);
                notification.info({ message: "更新配筋成功" });
            } else {
                onError(res&&res.data?res.data.code:'服务器未连接');
            }

        },
        *updatePileReinforcement({ payload:{ values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(renforceService.updatePileReinforcement, { ...values });
            
            if (res&&res.data && res.data.code == "200") {
                onSuccess(res);
                notification.info({ message: "更新配筋成功" });
            } else {
                onError(res&&res.data?res.data.code:'服务器未连接');
            }

        },
    }
}